package com.ruoyi.quartz.controller;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.quartz.domain.BaseArticle;
import com.ruoyi.quartz.domain.BaseMenu;
import com.ruoyi.quartz.service.IBaseArticleService;
import com.ruoyi.quartz.service.IBaseMenuService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/home")
public class HomeController extends BaseController {
    @Resource
    private IBaseMenuService iBaseMenuService;

    private IBaseArticleService iBaseArticleService;

    @Anonymous
    @GetMapping("/getMenu")
    public TableDataInfo list(BaseMenu baseMenu)
    {
        startPage();
        List<BaseMenu> list = iBaseMenuService.selectAll(baseMenu);
        return getDataTable(list);
    }

    @Anonymous
    @GetMapping("/getArticle")
    public TableDataInfo list(BaseArticle baseArticle) {
        List<BaseArticle> list = iBaseArticleService.selectAll(baseArticle);
        return getDataTable(list);
    }


    @Anonymous
    @GetMapping(value = "/getDetail/{art_id}")
    public AjaxResult getInfo(@PathVariable("art_id") Integer art_id)
    {
        return AjaxResult.success(iBaseArticleService.selectArticleById(art_id));
    }




}
